package com.itheima.pool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/*
使用工具类创建默认线程池
 */
public class Demo01 {
    public static void main(String[] args) throws InterruptedException {
        ExecutorService pool = Executors.newCachedThreadPool();
        for (int j = 0; j < 100; j++) {

            pool.submit(()->{
                for (int i = 0; i < 100; i++) {
                    System.out.println(Thread.currentThread().getName()+"执行"+i);
                }
            });
        }
        Thread.sleep(2000);
        pool.submit(()->{
            for (int i = 0; i < 100; i++) {
                System.out.println(Thread.currentThread().getName()+"执行"+i);
            }
        });
        pool.shutdown();
    }



}
